package com.heba.popupwindow;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.heba.greenmulu.R;


/**
 * Created by shenghao on 2015/5/26.
 */
public class PhotoPopupWindow extends BasePopupWindow implements View.OnClickListener {

    private Button btn1;
    private Button btn2;
    private Button btn3;

    private OnPhotoPopupClickListener onPhotoPopupClickListener;

    public PhotoPopupWindow(Context context) {
        super(LayoutInflater.from(context).inflate(
                R.layout.popup_photo, null));
        setAnimationStyle(R.style.Popup_Animation_Translate);
    }

    public PhotoPopupWindow(Context context, int width, int height) {
        super(context, LayoutInflater.from(context).inflate(
                R.layout.popup_photo, null), width, height);
        setAnimationStyle(R.style.Popup_Animation_Translate);
    }

    @Override
    public void initViews() {
        btn1 = (Button) findViewById(R.id.item_popupwindows_camera);
        btn2 = (Button) findViewById(R.id.item_popupwindows_Photo);
        btn3 = (Button) findViewById(R.id.item_popupwindows_cancel);
    }

    @Override
    public void initEvents() {
        btn1.setOnClickListener(this);
        btn2.setOnClickListener(this);
        btn3.setOnClickListener(this);
    }

    @Override
    public void init() {
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.item_popupwindows_camera:
                if (onPhotoPopupClickListener != null)
                    onPhotoPopupClickListener.onCameraClick();
                break;
            case R.id.item_popupwindows_Photo:
                if (onPhotoPopupClickListener != null)
                    onPhotoPopupClickListener.onAlbumClick();
                break;
            case R.id.item_popupwindows_cancel:
                if (onPhotoPopupClickListener != null)
                    onPhotoPopupClickListener.onCancelClick();
                break;
            default:
                break;
        }
        dismiss();
    }

    /**
     * @param onPhotoPopupClickListener
     */
    public void setOnPhotoPopupClickListener(OnPhotoPopupClickListener onPhotoPopupClickListener) {
        this.onPhotoPopupClickListener = onPhotoPopupClickListener;
    }

    /**
     * 回调接口 interface
     */
    public interface OnPhotoPopupClickListener {

        void onCameraClick();

        void onAlbumClick();

        void onCancelClick();
    }

}
